Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash if invalid row given. #114

Closed
wants to merge 4 commits into from
Closed

Conversation

vranki
Copy link

@vranki vranki commented Aug 25, 2014

Now the function checks if the row exists in the contact id list, and returns null if it doesn't instead of crashing.

@@ -700,7 +700,10 @@ bool SeasideFilteredModel::savePerson(SeasidePerson *person)

SeasidePerson *SeasideFilteredModel::personByRow(int row) const
{
return personFromItem(SeasideCache::itemById(m_contactIds->at(row)));
if(m_allContactIds->contains(row)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the correct behavior: imagine your m_allContactIds contains [0, 2], contains(2) returns true, while at(2) segfaults (trying to reach the 3rd item of the list). You should compare row to the size.

I would replace this by if (row >= 0 && row < m_allContactIds->size())

@vranki vranki closed this Aug 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants